package com.dci.controller.ms;

import com.dci.result.JsonData;
import com.dci.service.ms.MsRoleUserInfoService;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Copyright: 2019 姑苏区政府大数据中心
 * @Title: null.java
 * @Package com.acp.controller
 * @Description: 递归查询用户下的菜单
 * @author: 许高峰
 * @date: 2019/5/15 20:36
 */
@Controller
public class MsRoleUserInfoController {

    @Resource
    private MsRoleUserInfoService msRoleUserInfoService;

    @PostMapping("/queryMenuByUserId")
    @ResponseBody
    public JsonData queryMenuByUserId(@RequestParam(value = "token", required = false) String token, @RequestParam String systemType) {
        Claims claims = Jwts.parser().setSigningKey("itcast").parseClaimsJws(token).getBody();
        String userId = (String) claims.get("userId");
        JsonData jsonData = msRoleUserInfoService.queryMenuByUserId(userId, systemType);
        jsonData.setUserId(userId);
        return jsonData;
    }

}
